home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!trumpton.demon.co.uk
- From: Steve Clarke <steve@trumpton.demon.co.uk>
- Newsgroups: comp.lang.c++
- Subject: Question: Share and unlink
- Date: Sun, 14 Jan 1996 22:17:40 GMT
- Organization: Trumpton Fire Station
- Message-ID: <526557702wnr@trumpton.demon.co.uk>
- Reply-To: steve@trumpton.demon.co.uk
- X-NNTP-Posting-Host: trumpton.demon.co.uk
- X-Broken-Date: Sun, 14 Jan 1996 22:04:01 gmt0bst1
- X-Newsreader: Newswin Alpha 0.9
- X-Mail2News-Path: relay-4.mail.demon.net!post.demon.co.uk!trumpton.demon.co.uk
-
-
- I am using BC4.51, and am attempting to write a function to remove a file, with an
- share_unlink() function for use in a DOS C++ application.
-
- The file(s) I am trying to remove are opened regularly by other programs, and the
- function I am trying to write is:
-
- share_unlink(filename, delay)
-
- time1=read clock
- do
- time2=read clock
- time=time2-time1
- attempt to lock file
- while file_is_locked_by_another_program and time<delay
-
- if time<delay then
- remove file
-
- The only way I can see that I can lock the file is to sopen it for read. I must keep the file
- opened (or else someone else can access it) until I have deleted it - that is the problem !
-
- What I don't really want to do is to provide a critical error handler (unless I really have to)
- Has anybody got any ideas ?
-
- TIA.
-
- --
- Steve Clarke http://www.citynet.co.uk/users/trumpton
-
- C is a programming language with all of the power of assembly language,
- and all the readability of assembly language.
-
-